package com.aaa.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.util.StopWatch;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/5 9:56
 * @description：这辈子第二个拦截器
 * @modified By：
 * @version: 1.0
 */
@Component
public class MySecondInterceptor   implements WebRequestInterceptor {
    StopWatch stopWatch1= new StopWatch("chenjian");
    @Override
    public void preHandle(WebRequest request) throws Exception {
        System.out.println("xxxpreHandle执行啦");
        stopWatch1.start();
    }

    @Override
    public void postHandle(WebRequest request, ModelMap model) throws Exception {
        System.out.println("xxxpostHandle执行啦");
        stopWatch1.stop();
        System.out.println("xxx花费时间："+stopWatch1.getTotalTimeMillis());
    }

    @Override
    public void afterCompletion(WebRequest request, Exception ex) throws Exception {
        System.out.println("xxxafterCompletion执行啦");
    }
}
